<% if properties.any?{ |p| p.name == "labels" } -%>
if v, ok := d.GetOkExists("labels"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelsProp)) {
    // Labels cannot be set in a create.  We'll have to set them here.
    err = resource<%= resource_name -%>Read(d, meta)
    if err != nil {
        return err
    }

    obj := make(map[string]interface{})
    // d.Get("labels") will have been overridden by the Read call.
    labelsProp, err := expand<%= resource_name -%>Labels(v, d, config)
    if err != nil {
    	return err
    }
    obj["labels"] = labelsProp
    labelFingerprintProp := d.Get("label_fingerprint")
    obj["labelFingerprint"] = labelFingerprintProp

    url, err = replaceVars(d, config, "<%= "{{#{object.__product.name}BasePath}}#{object.self_link_uri}" -%>/setLabels")
    if err != nil {
        return err
    }
    res, err = sendRequest(config, "POST", project, url, userAgent, obj<%= object.error_retry_predicates ? ", " + object.error_retry_predicates.join(',') : "" -%>)
    if err != nil {
      return fmt.Errorf("Error adding labels to <%= resource_name -%> %q: %s", d.Id(), err)
    }

    err = computeOperationWaitTime(
        config, res, project, "Updating <%= resource_name -%> Labels", userAgent,
        d.Timeout(schema.TimeoutUpdate))

    if err != nil {
        return err
    }

}
<% end -%>
